import Store from 'electron-store'
import { v4 } from 'uuid';
class DataStore extends Store {
    constructor(setting) {
        super(setting);
        this.tracks = this.get('tracks') || []
    }

    saveTracks(){
        this.set('tracks',this.tracks)
        return this
    }

    getTracks(){
        return this.get('tracks') || []
    }

    addTracks(tracks){
        const tracksWithProps = {
            id:v4(),
            liveId:tracks.liveId,
            createTime:tracks.ctime,
            contents:tracks.contents,
            status:tracks.status
        }
        this.tracks.push(tracksWithProps)
        return this.saveTracks()
    }
    deleteTrack(deleteID){
        this.tracks = this.tracks.filter(item => item.id !== deleteID)
        return this.saveTracks()
    }
}
export default DataStore
